package main

import "fmt"

func adder() func(s int)int {
	sum := 0
	return func(v int) int {
		sum += v
		return sum
	}
}

type iAdder func(v int)(int,iAdder)

func adder2(base int) iAdder {
	return func(v int) (int, iAdder) {
		return base+v ,adder2(base+v)
	}
}

func main() {

	//a := adder()
	//for i:=0 ;i<10;i++{
	//	fmt.Println(a(i))
	//}
	a := adder2(0)
	for i:=0 ;i<10;i++{
		var  s  int
		s,a = a(i)
		fmt.Println(s)
		//fmt.Println(a(i))
	}
	//a = adder2(0)
	//for i:=0 ;i<10;i++{
	//	fmt.Println(adder2(i))
	//}

}
